package com.dashboard.tuyensinh;

import com.lb.jwitter.connectDatabase.ConnectTuyenSinh;
import com.opensymphony.xwork2.Action;

public class TyLeBacDaoTaoAction {
	private String jsonData;
	public String getJsonData() {
		return jsonData;
	}


	public void setJsonData(String jsonData) {
		this.jsonData = jsonData;
	}
	////////////////////////////////////////////////////////
	private String namHoc;

	public String getNamHoc() {
		return namHoc;
	}


	public void setNamHoc(String namHoc) {
		this.namHoc = namHoc;
	}
	/////////////////////////////////////////////////////////
	
	public String execute() throws Exception
	{
		ConnectTuyenSinh connection= new ConnectTuyenSinh();
		if(connection.getConnection()!=null){
			//namHoc="2014";
			
			if(namHoc==null||namHoc.length()<1){
				return Action.ERROR;
			}
			
			String query="select A.bacdaotao_id, B.ten, sum(tongSo) as tongSo"
					+" from tuyensinh A, bacdaotao B"
					+" where nam="+namHoc+" and A.bacdaotao_id=B.id"
					+" group by bacdaotao_id, B.ten";
			//[{"bacdaotao_id":"1","ten":"Đại học","tongSo":"5000"}]
			jsonData=connection.getJSonData(query);
			
			
		}
		connection.closeConnection();
		return Action.SUCCESS;

	}
}
